#include<vector>
#include<iostream>

using namespace std;

class Solution {
public:
	vector<int> productExceptSelf(vector<int>& nums) {
		int size = nums.size();
		vector<int> left(size),right(size),res(size);
		left[0] = 1;
		for (int i = 1; i < size; i++) left[i] = left[i-1] * nums[i-1];
		right[size - 1] = 1;
		for (int j = size - 2; j >= 0; j--) right[j] = right[j + 1] * nums[j+1];		
		for (int i = 0; i < size; i++) {
			res[i] = left[i] * right[i];
		}
		return res;
	}
};

int main() {
	Solution s;
	vector<int> arr = { 1,2 };
	s.productExceptSelf(arr);
}